-
-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Voxelization #1209
Voxelization #1209
Conversation
Thanks! and also to the tools I look it this week end! |
Can you provide information about the implemented algorithm? |
@kerautret and @copyme please hold on. @hadjiszs is an intern I have at Lyon and the code is not ready for review. I asked @hadjiszs to PR to be able to discuss on his code. |
ok let me know when ready but that nice idea ;) |
minor change
@hadjiszs have you checked the « allow edits from maintainers » when you've created your Pull-Request ? |
@dcoeurjo sorry I didn't know this option, but it seems checked |
@hadjiszs : since we do not optimize the intersection tests for adjacent triangles, I suggest to remove the mesh from the constructor and add a "voxelise(Mesh)" method. |
@dcoeurjo yes I think it's ok, maybe with a "add(Mesh)" method, and a voxelize() method? to be able to do something like that:
by the way, I try to fix last build fail of travis, but I really don't understand error about |
Even simpler:
no need to keep the meshes (or a ref to) as members. |
Don't bother with the HDF5 issue, I'll have a look. thx |
sorry I haven't explained my example, something like that (in voxelize method)
To let programmer add/remove meshes in MeshVoxelizer, and he chooses when he wants to run parallel voxelization of all current list of meshes he established. With that, he can have a parallel voxelization of a set of meshes but, there is no parallelism in MeshVoxelizer yet, so my proposition is useless for now and I think it would be eventually for later, and I will do like you said as of now |
I've updated the interface. Your tool may be deprecated now. |
can someone review this dude too ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first part of the review I will finish it tomorrow ;)
|
||
The approach is rather simple: Given a triangulated mesh, the | ||
MeshVoxlizer processes each triangle independently. If the triangle | ||
intersects a given @a template centered ot a given grid point, then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ot a given grid -> at a given grid
|
||
\section sectVoxelization2 Basic Usage | ||
|
||
Given a Mesh @a aMesh, the MeshVoxelizer class is template by a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is templateD
|
||
@snippet examples/shapes/exampleMeshVoxelizer.cpp MeshVoxelizerDig | ||
|
||
Once exported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Once exported with :" ?
|
||
we obtain the following voxel set: | ||
|
||
@image html resultCube.png "Resulting voxelSet (quad faces triangulated by the viewer)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps could you just use an export in off format and the visualize it with the DGtalTools meshViewer (to avoid to display triangle)..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by the way perhaps having another example with bunny or other will be nice to illustrate such new nice work ;)!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you use an imported mesh in the examples simply use:
#include <DGtal/io/readers/MeshReader.h>
aMesh << "bunny.off";
and then simply output in sdp format and display it with 3dSDPViewer for instance.
|
||
We then create a voxelization of a scaled version of the cube onto a | ||
@f$ 128^3@f$ domain: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add the header mention (#include "DGtal/shapes/MeshVoxelizer.h") just before this code ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, that is nice new features!
Just see some small assert add for the domain and then we can merge.
/** | ||
Description of template class 'IntersectionTarget' | ||
|
||
\brief Aim: A class for intersection target used on voxelization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"used for" ?
and mention MeshVoxelizer in parenthesis @see MeshVoxelizer ?
* @param [out] outputSet the set that collects the voxels. | ||
* @param [in] aMesh the mesh to voxelize (vertex coordinates will | ||
* be casted to @e PointR3 points. | ||
* @param [in] scaleFactor the scale factor to apply to the mesh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for this parameter perhaps you have to alter to be careful to not use a value compatible with the domain of the digital set, else we have an error... (or/and detect it explicitly later ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean ?
That the scale may induce voxels outside the set domain ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry something was auto completed with my editor, or I was very tired ;)
I was thinking that you could add a user warning in the doc to avoid this potential error. But with the last change, we can simply mention that outside domain voxel are ignored ?
* @param [in] a the first point of the triangle | ||
* @param [in] b the second point of the triangle | ||
* @param [in] c the third point of the triangle | ||
* @param [in] scaleFactor the scale factor to apply to the triangle (default=1.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
src/DGtal/shapes/MeshVoxelizer.ih
Outdated
|
||
// check if current voxel projection is inside ABC projection | ||
if(pointIsInside2DTriangle(AA, BB, CC, pp) != OUTSIDE) | ||
outputSet.insert(v); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here I got an error if the scaleFactor is too large (v is outside the output domain, see previous remarks).
A = a*scaleFactor; | ||
B = b*scaleFactor; | ||
C = c*scaleFactor; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps add an assert to check if the points are in the digital set domain ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I've slightly changed the interface: I first check that the voxel is inside the domain or not before the insert. Hence, no more issue with the domain but if a voxel is outside the set, it is simply skipped.
Fine for you ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes fine
Thanks for your comments. |
Could you please generate the images with the bunny and 2 digitizations using different resolution (I'm not familiar with the mesh viewer) ? |
thx @kerautret |
I've updated the doc with the bunny images. Would it be fine for you ? |
@kerautret is it fine for you? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes nice thanks just a typo, sorry for the delay ;(
@@ -84,6 +84,11 @@ be automatically triangulated using a naive fan approach. Hence, if | |||
the face in not planar and/or convex, the resulting digitization might | |||
be incorrect. | |||
|
|||
Here you have another example with a more complex mesh (using DGtaltools tools for visualization): | |||
|
|||
@image html bunnies.png "Voxelization at different resolution of a Stanford Bunny." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
different resolutionS ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damit ;)
thanks looks fine, just waiting for travis and merging.... |
travis done ;) |
PR Description
Algorithm
I traverse all voxels V of triangle bounding box and insert in digital set if V overlaps current triangle.
I use intersection target (samuli laine) to know if a voxel overlaps a triangle.
6-separated
26-separated
It's the same algorithm but I do differently of 6-separated way for projections.
Checklist
cmake
mode (otherwise, Travis C.I. will fail).